/**
 * 
 * @author Adam Perez
 * This JUnit creates a default player with a ship. Then it 
 * modifies the cargo and fuel on the ship.
 * It then performs various tests of checking if the ship is 
 * the cargo is full, if the cargo is empty,
 * if something was to the cargo, if something was removed
 *  from the cargo, and checks the fuel level.
 */

import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;


import org.junit.Before;
import org.junit.Test;

/**
 * @author Adam Perez
 * @version 1.0
 */
public class TestShip {
	/**
	 * Field testPlayer.
	 */
	private Player testPlayer;

	/**
	 * Field testShip.
	 */
	private SpaceShip testShip;

	/**
	 * toString method.
	
	 * @return String */
	public String toString() {
		return "";
	}
	
	/**
	 * Method start.
	 */
	@Before
	public void start() {
		testPlayer = new Player("TestName", 4, 4, 4, 4, 1000);
		testShip = testPlayer.getShip();
	}

	/**
	 * This method tests to see if the ship with no cargo has a full cargo.
	 */
	@Test
	public final void testIsShipFull() {
		assertFalse("assertion failed", testShip.isFull());
	}

	/**
	 * This method tests to see if the ship with no cargo has no cargo.
	 */
	@Test
	public final void testIsShipEmpty() {
		assertTrue("assertion failed", testShip.isEmpty());
	}

	/**
	 * This method fills the cargo of a ship and then tests to see
	 *  if the ship has a full cargo load.
	 */
	@Test
	public final void testisFullShipFull() {
		final int[] newGoods = new int[10];
		newGoods[0] = 15;
		testShip.setGoods(newGoods);
		assertTrue("assertion failed", testShip.isFull());
	}

	/**
	 * This method tests to see if a ship with a full
	 *  amount of fuel has a full amount of fuel.
	 */
	@Test
	public final void testIsShipFuelFull() {
		assertTrue("assertion failed", testShip.isFuelFull());
	}

	/**
	 * This method tests to see if a ship with a full
	 *  amount of fuel as an empty fuel level.
	 */
	@Test
	public final void testIsShipFuelEmpty() {
		assertFalse("assertion failed", testShip.getFuel() == 0);
	}

	/**
	 * This method sets the fuel to empty and checks to make sure it is empty.
	 */
	@Test
	public final void testIsEmptyShipFuelEmpty() {
		testShip.setFuel(0);
		assertTrue("assertion failed", testShip.getFuel() == 0);
	}

	/**
	 * This method adds 10 food to the ship and then checks to make sure it has 10 food.
	 */
	@Test
	public final void testAddingFood() {
		final int[] newGoods = new int[10];
		newGoods[2] = 10;
		testShip.setGoods(newGoods);
		assertTrue("assertion failed", testShip.getGoods()[2] == 10);
	}

	/**
	 * This method adds 10 food to the ship. Then it subtracts
	 *  one and checks to make sure it has 9.
	 */
	@Test
	public final void testRemovingFood() {
		final int[] newGoods = new int[10];
		newGoods[2] = 10;
		testShip.setGoods(newGoods);
		testShip.getGoods()[2]--;
		assertTrue("assertion failed", testShip.getGoods()[2] == 9);
	}

	/**
	 * Method testCargoAmount.
	 */
	@Test
	public final void testCargoAmount() {
		final int[] newGoods = new int[10];
		newGoods[0] = 5;
		newGoods[1] = 3;
		newGoods[2] = 2;
		newGoods[3] = 2;
		newGoods[4] = 3;
		testShip.setGoods(newGoods);
		assertTrue("assertion failed", testShip.getCargo() == 15);
	}
	

}
